home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / falcon / nt_dsp2.lzh / NT_DSP2.MSA / BENCH / 5-56.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-07-18  |  3.9 KB  |  98 lines

  1.     page 132,66,0,6
  2.     opt    rc
  3. ;*******************************************
  4. ;Motorola Austin DSP Operation  June 30,1988
  5. ;*******************************************
  6. ;DSP56000/1
  7. ;8 pole 5 multiply cascaded canonic IIR filter
  8. ;File name: 5-56.asm
  9. ;**************************************************************************
  10. ;    Maximum sample rate: 353.5 Khz at 20.5 MHZ/ 465.5 KHz at 27.0 MHz
  11. ;    Memory Size: Prog: 6+11 words ; Data :4*(2+5) words
  12. ;    Number of clock cycles:    58 (29 instruction cycles)
  13. ;    Clock Frequency:    20.5MHz/27.0MHz
  14. ;    Cycle time:        97.5ns /  74.1ns
  15. ;**************************************************************************
  16. ;    This IIR filter reads the input sample
  17. ;    from the memory location Y:input
  18. ;    and writes the filtered output sample
  19. ;    to the memory location Y:output
  20. ;
  21. ;    The samples are stored in the X memory
  22. ;    The coefficients are stored in the Y memory
  23. ;**************************************************************************
  24. ;
  25. ;    The equations of the filer are:
  26. ;       w(n) =    x(n) - ai1*w(n-1) - ai2*w(n-2)
  27. ;       y(n) = b0*w(n) + bi1*w(n-1) + bi2*w(n-2)
  28. ;
  29. ;                     w(n)
  30. ;   x (n)------(-)---------->-|->---bi0---(+)-------> y(n)
  31. ;               A             |            A
  32. ;               |            1/z           |
  33. ;               |             | w(n-1)     |
  34. ;               |             v            |
  35. ;               |-<--ai1----<-|->---bi1-->-|
  36. ;               |             |            |
  37. ;               |            1/z           |
  38. ;               |             | w(n-2)     |
  39. ;               |             v            |
  40. ;               |-<--ai2----<--->---bi2-->-|
  41. ;
  42. ;
  43. ;    All coefficents are divided by 2:
  44. ;    w(n)/2=      x(n)/2 - ai1/2*w(n-1) -ai2/2*w(n-2)
  45. ;    y(n)/2= bi0/1*w(n)/2 + bi1/2*w(n-1) +bi2/2*w(n-2)
  46. ;
  47. ;       X Memory Organization            Y Memory Organization
  48. ;                           |   b0N/2 | Coef. + 5*nsec-1
  49. ;         |         |                          |   b1N/2 |
  50. ;         |         |                          |   b2N/2 |
  51. ;         |         |                          |   a1N/2 |
  52. ;         |         |                          |   a2N/2 |
  53. ;         | wN(n-1) | Data + 2*nsec-1          |    .    |
  54. ;         | wN(n-2) |                          |   b01/2 |
  55. ;         |   .     |                          |   b11/2 |
  56. ;         |   .     |                          |   b21/2 |
  57. ;         | w1(n-1) |                          |   a11/2 |
  58. ;    R0 ->| w1(n-2) | Data                R4 ->|   a21/2 | Coef.
  59. ;         |         |                          |         |
  60. ;
  61. ;*************************************************************************
  62. ;
  63. ;    initialization
  64. ;**********************
  65. nsec    equ    4
  66. start    equ    $40
  67. data    equ    0
  68. coef    equ    0
  69. input    equ    $ffe0
  70. output  equ    $ffe1
  71. igain    equ    0.5
  72.  
  73.     ori     #$08,mr              ;set scaling mode
  74.     move    #data,r0                  ;point to filter states
  75.     move    #coef,r4              ;point to filter coefficients
  76.     move    #2*nsec-1,m0                                  
  77.     move    #4*nsec-1,m4                                      
  78.     move    #igain,y1                 ;y1=initial gain
  79. ;
  80.     opt     cc
  81. ;      filter loop: 5*nsec+9
  82. ;*************************************************                                   
  83.     movep   y:input,y0                         ;get sample
  84.     mpy    y0,y1,a     x:(r0)+,x0  y:(r4)+,y0  ;x0=1st section w(n-2),y0=a12/2
  85. ;
  86.     do       #nsec,_ends                 ;do each section
  87.     mac    -x0,y0,a     x:(r0)-,x1  y:(r4)+,y0  ;x1=w(n-1) ,y0=ai1/2
  88.     macr   -x1,y0,a     x1,x:(r0)+  y:(r4)+,y0  ;push w(n-1) to w(n-2),y0=bi2/2
  89.     mac    x0,y0,a     a,x:(r0)    y:(r4)+,y0  ;push w(n) to w(n-1),y0=bi1/2
  90.     mac    x1,y0,a     x:(r0)+,x0  y:(r4)+,y0  :get this iter w(n),y0=bi0/2
  91.     mac    x0,y0,a     x:(r0)+,x0  y:(r4)+,y0  ;next iter:x0=w(n-2),y0=ai2/2
  92. _ends
  93.     rnd    a                  ;round result
  94.     movep        a,y:output    ;output sample
  95. ;*************************************************                                   
  96.     end
  97.  
  98.